-
Notifications
You must be signed in to change notification settings - Fork 0
Upload of the superquickstart #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Upload of the superquickstart #140
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mariegrho
the super-qiuckstart looks already very good :) I've many commented on some of the wording. It might be good if you check for typos at the end.
Thanks for the great work!
| 2. __Model:__ | ||
| Our model will be defined as a python function. | ||
| We will then assign it to our Simulation object by `.model` | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: "We will then assign it to our Simulation object by accessing the .model attribute"
|
|
||
| 3. __Observations:__ | ||
| Our observation data needs to be structured as a [xarray.Dataset](https://docs.xarray.dev/en/stable/generated/xarray.Dataset.html). | ||
| We assign it to our Simulation object by `.observations.` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: "We assign it to the .observations attribute of our simulation object"
|
|
||
| 4. __Solver:__ | ||
| Solvers are needed to solve the model. | ||
| In our simple case, we will use the solver "solve_analytic_1d" from the "pymob.solver.analytic module. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe mention, that the solve_analytic_1d solver basically does nothing, because the model already contains the solution. It is only needed to satisfy pymob, which requires a solver
| We assign the parameters to our Simulation object by `sim.model_parameters`. This is a dictionary that holds the model input data. The keys it takes by default are `parameters`, `y0` and `x_in`. | ||
|
|
||
| 7. __Evaluator:__ | ||
| The Evaluator is an instance to evaluate a model. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- is before 6.
| Pymob supports our modeling process by providing several tools for *structuring our data*, for the *parameter estimation* and *visualization of the results*. | ||
|
|
||
| Before starting the modeling process, we let's have a look at the main steps and modules of pymob: | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about another heading here "pymob components" or similar?
| data_obs = xr.DataArray(y_obs, coords={"t": t}).to_dataset(name="y") | ||
| data_obs | ||
| ``` | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice and clear! :)
|
|
||
| ## Estimating parameters | ||
|
|
||
| We are almost set infer the parameters of the model. We add another parameter to also estimate the error of the parameters, We use a lognormal distribution for it. We also specify an error model for the distribution. This will be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are almost set to infer...
...parameters and use a lognormal distribution for it.
| Our model is now prepared with a parameter set. | ||
| In order to intialize the *Evaluator* class, we need to execute `sim.dispatch_constructor()`. | ||
| This step is very important and needs to be done everytime when we made changes in our model. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... after making changes to our model
| sim.config.model_parameters.b.min = -5 | ||
| sim.config.model_parameters.b.max = 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The min/max parameters are not needed when running inference with numpyro, so I suggest to remove them, otherwise it might be confusing
| ### Estimating parameters and uncertainty with MCMC | ||
|
|
||
| Of course this example is very simple, we can in fact optimize the parameters perfectly by hand. But just for the fun of it, let's use *Markov Chain Monte Carlo* (MCMC) to estimate the parameters, their uncertainty and the uncertainty in the data. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would rather fit before the previous block.
|
Hi @amelieleo, thanks for uploading the introduction. I like it a lot :) Of course I still have a few remarks:
Please remove the base module from 4. solver. This only contains utility functions and the Base parent class for the other solvers
This is not quite clear to me. What does
typo "oon" (highlighted)
I would like to add a dispatch_constructor info-box:
We could also add a loss-function which is just the SSE = ((results.data - obs.data) ** 2).sum(dim="time"). and add it's value as a text to the plot
This could be nice for people, to see how results and obs are automatically aligned.
typo "shloud" Use of API referencesI also have a general remark regarding cross references to the API. @mariegrho @amelieleo @merkuns: When you write the guides, please use as often as reasonably possible direct API references wherever possible. E.g.: instead of (use {class} for classes, and {meth} for methods; see https://www.sphinx-doc.org/en/master/usage/domains/python.html#cross-referencing-python-objects). The difference is that with the former, links to the respective API documentation will be automatically inserted. The path is the full path to the respective class @amelieleo, @mariegrho can you look over the documents and replace class and method mentions with references? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is complete @mariegrho @amelieleo 🎉
For @merkuns tutorial we will open a separate PR
… and added a question as a comment in the code
|
@merkuns thanks for providing the first version of the ODE system tutorial. I like it a lot! One thing I noticed when I tried to build the documentation is that the script cannot be executed as a whole (which is required for automated documentation deployment). This is because you build in errors, which I like a lot. The way to work with this is to use a try-except block catching the error you want to produce and then printing it as a message without raising an error. You could also raise an error if the normal function call does not produce an error 🤪 To try to build and preview the documentation and check whether this runs without errors, you can execute the commands in the docs/README.md sections 'Using jupyter notebooks for the documentation' and 'Compile documentation'. These should run without errors Some other comments
|
short version of the quickstart, first draft